package edu.xidian.bdilab.jrbigdata.controller.enterprise;


import edu.xidian.bdilab.jrbigdata.controller.response.ResponseResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import edu.xidian.bdilab.jrbigdata.service.enterprise.requirementRelease.RequirementRelease;

import javax.servlet.http.HttpSession;
import java.util.List;

@CrossOrigin
@RestController
@Api(tags = {"RequirementRelease-企业需求发布相关功能"})
public class RequirementReleaseController {
    @Autowired
    public RequirementRelease RequirementRelease;
    @ApiImplicitParams({
            @ApiImplicitParam(name = "socialCode", value = "统一社会信用代码"),
            @ApiImplicitParam(name = "enterpriseName", value = "企业名称"),
            @ApiImplicitParam(name = "loanLimit", value = "贷款额度(枚举)"),
            @ApiImplicitParam(name = "lowerLimmit", value = "利率下限（单位%）"),
            @ApiImplicitParam(name = "upperLimmit", value = "利率上限（单位%）"),
            @ApiImplicitParam(name = "loanPeriod", value = "贷款期限（单位：月）"),
            @ApiImplicitParam(name = "guaranteeMode", value = "担保方式(枚举)"),
            @ApiImplicitParam(name = "financingPurposes", value = "融资用途(枚举)"),
            @ApiImplicitParam(name = "projrctSituation", value = "项目情况"),
            @ApiImplicitParam(name = "remark", value = "备注")
    })
    @RequestMapping(value = "enterprise/requirementRelease", method = RequestMethod.POST)
    public ResponseResult enterprise_requirementRelease  (@RequestParam String socialCode,
                                                          @RequestParam String enterpriseName,
                                                          @RequestParam int loanLimit,
                                                          @RequestParam double lowerLimmit,
                                                          @RequestParam double upperLimmit,
                                                          @RequestParam int loanPeriod,
                                                          @RequestParam int guaranteeMode,
                                                          @RequestParam String financingPurposes,
                                                          @RequestParam String projrctSituation,
                                                          @RequestParam String remark) {

        //发布时默认为公开需求
        ResponseResult responseResult = RequirementRelease.
                requirementReleasenterprise(socialCode,
                        enterpriseName,
                        loanLimit,
                        lowerLimmit,
                        upperLimmit,
                        loanPeriod,
                        guaranteeMode,
                        financingPurposes,
                        projrctSituation,
                        remark);
        return responseResult;
    }
    @ResponseBody
    @ApiOperation("查询所有企业公开需求")
    @RequestMapping(value = "enterprise/getAllPublicReq", method = RequestMethod.POST)
    public ResponseResult getAllPublicReq(@RequestParam(defaultValue = "1")@ApiParam(value = "页码") int pageNum,
                                          @RequestParam(defaultValue = "10")@ApiParam(value = "每页记录数") int pageSize,
                                          @RequestParam(required = false) @ApiParam(value = "企业名称（支持模糊查询）") String enterpriseName,
                                          @RequestParam(required = false) @ApiParam(value = "企业代码（支持模糊查询）") String socialCode,
                                          HttpSession httpSession) throws Exception{
        ResponseResult responseResult = RequirementRelease.getAllPublicReq(pageNum,pageSize,enterpriseName,socialCode);
        return responseResult;
    }
}
